import Vue from 'vue'
import VueRouter from 'vue-router'
import PageRouter from './views/page'
import ViewsRouter from './views/'
Vue.use(VueRouter)

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return {
                x: 0,
                y: to.meta.savedPosition || 0
            }
        }
    },
    routes: []
})

router.addRoutes([...ViewsRouter, ...PageRouter])

export default router